package com.oocl.heather.util;

import java.io.File;
import com.oocl.heather.cmd.impl.CatCommand;
import com.oocl.heather.cmd.impl.CdCommand;
import com.oocl.heather.cmd.impl.CpCommand;
import com.oocl.heather.cmd.impl.LsCommand;
import com.oocl.heather.cmd.impl.MkdirCommand;
import com.oocl.heather.cmd.impl.PwdCommand;
import com.oocl.heather.cmd.impl.RmCommand;
import com.oocl.heather.cmd.impl.TouchCommand;

public class Command {

	public String getCommands(String command,File curren){
		String result;
		String c;
		if(command.contains(" ")){
			c=command.substring(0, command.indexOf(" "));
		}
		else{
			c=command;
		}
		switch(c){
		case "ls":
			result=new LsCommand().lscommand(command, curren);
			System.out.println();
			break;
        case "cd":
        	result=new CdCommand().cdcommand(command, curren);
			System.out.println();
			break;
        case "mkdir":
        	result=new MkdirCommand().mkdircommand(command, curren);
        	System.out.println();
        	break;
        case "cp":
        	result=new CpCommand().cpcommand(command, curren);
        	System.out.println();
        	break;
        case "rm":
        	result=new RmCommand().rmcommand(command, curren);
        	System.out.println();
        	break;
        case "touch":
        	result=new TouchCommand().touchcommand(command, curren);
        	System.out.println();
        	break;
        case "cat":
        	result=new CatCommand().catcommand(command, curren);
        	System.out.println();
        	break;
        case "pwd":
        	result=new PwdCommand().pwdcommand(command, curren);
        	System.out.println();
        	break;
        default:
        	result="Your input command is incorrect!\r\n";
        	System.out.println("Your input command is incorrect!\r\n");
		}
		return result;
		
	}
	
	
}
